
#include "../common/error.h"
#include "../common/mem.h"
#include <stdarg.h>

void fatal_error(const char* msg)
{
	fprintf(stderr, "Error: %s\n", msg);
	free_all(); /*  deallocate all allocated memory */
	exit(-1);
}

void validate_allocation(void* ptr, const char* allocated_subject)
{
	char buffer[1024];

	sprintf(buffer, "Could not allocate %s", allocated_subject);

	if (ptr == 0)
		fatal_error(buffer);
}

void nice_exit(const char* msg, ...)
{
	va_list argptr;

	va_start(argptr, msg);

	vfprintf(stderr, msg, argptr);

	free_all(); /*  deallocate all allocated memory */
	exit(0);
}


void debug_output(const char* msg, ...)
{
	/*
	va_list argptr;
	va_start(argptr, msg);
	vfprintf(stderr, msg, argptr);*/
}